package extreme.tddscaffold;

public class GildedRose {
    Item items;

    public GildedRose(Item items) {
        this.items = items;
    }

    public Item updateQuality() {
        //陈年干酪
        if (items.name.equals("Aged Brie")) {
            if (items.sellIn > 0) {
                return items;
            } else if (items.sellIn <= 0) {
                for (int i = 0; i <= 0 - items.sellIn; i++) {
                    items.quality += 1;
                }
            }
            return items;
        }
        //后台门票
        else if (items.name.equals("Backstage pass)")) {
            if (items.sellIn > 10) {
                return items;
            } else if (items.sellIn <= 10 && items.sellIn > 5) {
                for (int i = 10; i >= items.sellIn; i--) {
                    items.quality += 2;
                }
                return items;
            } else if (items.sellIn <= 5) {
                for (int i = 5; i >= items.sellIn; i--) {
                    items.quality += 2;
                }
            } else if (items.sellIn < 0) {
                items.quality = 0;
            }
            return items;
        }
        //萨弗拉斯
        else if (items.name.equals("Sulfuras")) {
            items.quality = items.quality;
            return items;
        }
        //普通商品else
        else if (!items.name.equals("Sulfuras") && items.name.equals("Sulfuras") && items.name.equals("Sulfuras")) {
            if (items.sellIn >= 0) {
                for (int i = 0; i < items.sellIn; i++) {
                    items.quality = items.quality - 1;
                }
            } else {
                for (int i = 0; i < 0 - items.sellIn; i++) {
                    items.quality = items.quality - 2;
                }
            }
            return items;
        }
        return items;
    }
}